
// INCLUDES ********************************************************************

#include "AccelerationDelegate.h"

#include "AccelerationController.h"



// NAMESPACES ******************************************************************

namespace 
{
    const float gRefreshRate = 30.0f;
}

// FORWARD DECLARATIONS ********************************************************

// *****************************************************************************

#pragma mark -
#pragma mark Constructor/Destructor
// -----------------------------------------------------------------------------

@implementation AccelerationDelegate

- ( id)init
{
    self = [super init];
    
    if ( self == nil)
    {
        return nil;
    }
    
    UIAccelerometer* globalAccelerometer = [UIAccelerometer sharedAccelerometer];
    
    globalAccelerometer.delegate = self;
    
    globalAccelerometer.updateInterval = 1 / gRefreshRate;
    
    return self;
}

#pragma mark -
#pragma mark Accelerometer
// -----------------------------------------------------------------------------

/// @todo THIS WILL BE DEPRECATED IN IOS 5.0 ?( COREMOTION)
- ( void) accelerometer:( UIAccelerometer*) accelerometer 
          didAccelerate:( UIAcceleration*) acceleration
{
    //NSLog(@"X: %g, Y: %g, Z: %g", acceleration.x, acceleration.y, acceleration.z);
    
    Meteor::AccelerationController::Instance().DeviceDidAccelerate( acceleration.x,
                                                                           acceleration.y,
                                                                           acceleration.z);
}


@end
